home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Controls
/
Visual Basic Controls.iso
/
vbcontrol
/
asppw112
/
freadwri.asp
< prev
next >
Wrap
Text File
|
1999-01-07
|
2KB
|
64 lines
<HTML><BODY>
<%
' ReadFile(ByVal vsPathName As String) As String
' output: file contents as string
' "" Failure
' WriteFile(ByVal vsPathName As String, ByVal vsFileBuff As String) As Integer
' output: >=0 Bytes written
' -1 Failure
'
'
' This file is provided as part of ASP Power Widgets Samples
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
' PURPOSE.
' Sample Operation:
' Pick up a file in virtual directory of "/", read it and write it to a new file demo.bin
' Copyright 1997-1998. All rights reserved.
' Dalun Software Inc. ASPPW 1.1
' http://www.dalun.com
' http://members.tripod.com/ActiveServerPage/
sDirName = Server.MapPath("/")
response.write "<p><h2>Pick up a file in directory """ & sDirName & """ .</h2></p>"
Set oFDMgt = Server.CreateObject("ASPPW.FDMgt")
if oFDMgt.ReadDir(sDirName)= -1 then
response.write "Read Directory Action Failed.<br>"
response.write oFDMgt.GetLastErrDescription
else
Set oFilelist = ofdmgt.Files
if oFilelist.count =0 then
response.write "Demo cann't proceed since there is no file in " & sDirName & "."
else
set file=oFilelist.Item(1)
response.write "<font size=2 face=""Courier New"">" & file.Name & "</font><br>"
buff = ofdmgt.ReadFile(sDirName & "\" & file.Name )
if buff="" and oFDMgt.GetLastErrNum <> 0 then
response.write "<br>Error: " & oFDMgt.GetLastErrDescription
else
response.write "<font color=""#800000""><pre>" & server.htmlencode(buff) & "</pre></font>"
j = ofdmgt.writeFile(sDirName & "\" & "demo.bin" , buff)
response.write cstr(j) & " bytes written to " & sDirName & "\" & "demo.bin.<br>"
end if
end if
Set oFilelist =nothing
end if
Set oFDMgt = nothing
%>
</BODY></HTML>